//
//  RealNameInfoViewController.m
//  YiBaoStore
//
//  Created by 吕清毅 on 2018/11/25.
//  Copyright © 2018年 小河. All rights reserved.
//

#import "RealNameInfoViewController.h"

@interface RealNameInfoViewController ()

@end

@implementation RealNameInfoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    //[self setMainView];
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self getHttpData];
}

- (void)getHttpData
{
    [[HttpRequest currentHttpRequest]postPath:RealName_API params:nil resultBlock:^(id Data, MsgModel *msgModel) {
        [self setMainView:Data[@"name"] and:Data[@"idNumber"]];
    }];
}

- (void)setMainView:(NSString *)name and:(NSString *)idCard
{
    self.bgNavView.hidden = YES;
    UIImageView *backView = [UIImageView new];
    backView.frame = CGRectMake(0, 0, SCREENWIDTH, 0.75*SCREENHEIGHT);
    backView.image = [UIImage imageNamed:@"realNameBack"];
    backView.backgroundColor = [UIColor clearColor];
    backView.userInteractionEnabled = YES;
    [self.view addSubview:backView];
    
    UIView *navi = [UIView new];
    navi.frame = CGRectMake(0, 0, SCREENWIDTH, TopBarHeight);
    navi.backgroundColor = ClearColor;
    [backView addSubview:navi];
    
    UIImageView *leftIV = [UIImageView new];
    leftIV.frame = CGRectMake(15, navi.height-15-18, 18, 14);
    leftIV.image = [UIImage imageNamed:@"back"];
    [navi addSubview:leftIV];
    
    UIButton *leftBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    leftBtn.frame = CGRectMake(8, navi.height-40, 32, 28);
    leftBtn.backgroundColor = ClearColor;
    [leftBtn addTarget:self action:@selector(leftBtnBackClick) forControlEvents:UIControlEventTouchUpInside];
    [navi addSubview:leftBtn];
    
    UILabel *titleLab = [UILabel new];
    CGFloat left = 30+18;
    titleLab.frame = CGRectMake(left, navi.height-13-18, SCREENWIDTH-96, 18);
    titleLab.textColor = UIColorFromHex(0x282727);
    titleLab.tag = 30;
    titleLab.font = FontSemiboldSize(18);
    titleLab.text = @"实名信息";
    titleLab.textAlignment = NSTextAlignmentCenter;
    [navi addSubview:titleLab];
    
    UIImageView *mainIV = [UIImageView new];
    mainIV.frame = CGRectMake(52, navi.bottom+40, SCREENWIDTH-104, 234);
    mainIV.image = [UIImage imageNamed:@"realName"];
    [backView addSubview:mainIV];
    
    UILabel *desLab = [UILabel new];
    desLab.frame = CGRectMake(0, mainIV.bottom+50, SCREENWIDTH, 30);
    desLab.textColor = titleColor;
    desLab.font = FontSemiboldSize(22);
    desLab.attributedText = [TTKUtil getAtttributeStringWithLineSpace:0 kern:2 and:@"已实名认证"];
    desLab.textAlignment = NSTextAlignmentCenter;
    [backView addSubview:desLab];
    
    UIView *bottomView = [UIView new];
    bottomView.frame = CGRectMake(0, backView.bottom, SCREENWIDTH, 0.25*SCREENHEIGHT);
    bottomView.backgroundColor = TotalWhite;
    [self.view addSubview:bottomView];
    
    UIImageView *realIV = [UIImageView new];
    realIV.frame = CGRectMake(35, bottomView.height-BottomHeight-49-16, 16, 16);
    realIV.image = [UIImage imageNamed:@"name"];
    [bottomView addSubview:realIV];
    
    UILabel *nameLab = [UILabel new];
    nameLab.frame = CGRectMake(realIV.right+10, realIV.top-3, 100, 22);
    nameLab.textColor = UIColorFromHex(0x343434);
    nameLab.font = FontMediumWithSize(16);
    nameLab.text = name;
    [bottomView addSubview:nameLab];
    
    UILabel *idCardLab = [UILabel new];
    idCardLab.frame = CGRectMake(SCREENWIDTH-20-152, realIV.top-2, 152, 20);
    idCardLab.textColor = UIColorFromHex(0x343434);
    idCardLab.font = FontMediumWithSize(14);
    idCardLab.text = idCard;
    [bottomView addSubview:idCardLab];
    
    UIImageView *idCardIV = [UIImageView new];
    idCardIV.frame = CGRectMake(idCardLab.left-10-16, realIV.top, 16, 16);
    idCardIV.image = [UIImage imageNamed:@"idCard"];
    [bottomView addSubview:idCardIV];
    
}

- (void)leftBtnBackClick
{
    [self.navigationController popViewControllerAnimated:YES];
}
@end
